<?php
/**
 * 示例model（标注表的作用）
 * panglishan
 * 2020.08.13
 */
namespace App\Models\MainDB;

use App\Services\Tools\HelperService;
use Illuminate\Database\Eloquent\Model;

class VirusBossBloodNextPrize extends Model{

    protected $table = 'ln_virus_boss_blood_next_prize';     //数据库内完整表名

    protected $primaryKey = 'id';    //主键名

    protected $fillable = [
        'id',      //主键ID
        'gift_id',         //礼物id
        'number',         //数量
        'sold',         //是否下架：1 否  2是
        'type',      //1一连 2十连 3百连 4特殊奖池
    ];

    public $timestamps = false;

    //获取奖品列表
    public function getWinJackpotList() {
        $data = $this->from('ln_virus_boss_blood_next_prize as a')
            ->select('a.id', 'a.gift_id', 'a.number', 'b.name as gift_name', 'b.price', 'b.picture', 'b.special')
            ->leftJoin('ln_gift as b', 'a.gift_id', '=', 'b.id')
            ->paginate(20);
        foreach ($data as $v){
            $v->gift_rank = HelperService::giftRank($v->price);
        }
        return $data;
    }
}